from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@localhost/test'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)


class Goods(db.Model):
    __tablename__ = 'goods'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    price = db.Column(db.Float)
    nums = db.Column(db.Integer)
    model = db.Column(db.String(64))
    phone = db.Column(db.String(64))

@app.route('/')
def list_goods():
    return render_template('index.html', data=Goods.query.all())


if __name__ == '__main__':
    app.run()
